var React = require('react');
import reqwest from 'reqwest';
import {
  Button
} from 'amazeui-react';
// import Button from 'amazeui-react/lib/Button'

class World extends React.Component {
  constructor() {
    super();
    this.handleClick = this.handleClick.bind(this);
    this.fetch = this.fetch.bind(this);
  }

  handleClick() {
    console.log(1);
    require.ensure([], (require) => {
      require('./test')
    });
    this.fetch('/admin/ticket/route',{},'test');
  }

  fetch(url,data,type) {
    reqwest({
      url: url,
      method: 'post',
      data: data,
      type:'json',
      withCredentials: false,
      success: (data) => {
        console.log(data);
      },
      error: (err) => {
        console.log(err);
      }
    })
  }

  render() {

    return(
      <div>
        <div>参数值为：{this.props.params.id}</div>
        <Button amStyle="success" onClick={this.handleClick}>click me</Button>
      </div>
    )
  }
}

// export default Hello;
module.exports = World;
